package edu.hm.risikomanagement;

import edu.hm.risikomanagement.library.DatabaseData;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class start extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		final Button btn_Risiken_verwalten = (Button) findViewById(R.id.btn_Risiken_verwalten);
		final Button btn_Risikouebersicht = (Button) findViewById(R.id.btn_Risikouebersicht);
		final Button btn_Benutzerverwaltung = (Button) findViewById(R.id.btn_Benutzerverwaltung);
		final Button btn_Einstellungen = (Button) findViewById(R.id.btn_Einstellungen);
		final Button btn_About = (Button) findViewById(R.id.btn_About);

		btn_Risiken_verwalten.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {

				if (DatabaseData.isNetworkAvailable(getApplicationContext())) {
					Intent i = new Intent(start.this, RisikenVerwalten.class);
					startActivity(i);
				} else {
					Intent i = new Intent(start.this, Error.class);
					i.putExtra("error", getString(R.string.connection_error));
					startActivityForResult(i, 1);
				}

			}
		});

		btn_Risikouebersicht.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {

				if (DatabaseData.isNetworkAvailable(getApplicationContext())) {
					Intent i = new Intent(start.this, RisikoUebersicht.class);
					startActivity(i);
				} else {
					Intent i = new Intent(start.this, Error.class);
					i.putExtra("error", getString(R.string.connection_error));
					startActivityForResult(i, 1);
				}

			}
		});

		btn_Benutzerverwaltung.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {

				if (DatabaseData.isNetworkAvailable(getApplicationContext())) {
					Intent i = new Intent(start.this, Benutzerverwaltung.class);
					startActivity(i);
				} else {
					Intent i = new Intent(start.this, Error.class);
					i.putExtra("error", getString(R.string.connection_error));
					startActivityForResult(i, 1);
				}

			}
		});

		btn_Einstellungen.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {

				if (DatabaseData.isNetworkAvailable(getApplicationContext())) {
					Intent i = new Intent(start.this, Einstellungen.class);
					startActivity(i);
				} else {
					Intent i = new Intent(start.this, Error.class);
					i.putExtra("error", getString(R.string.connection_error));
					startActivityForResult(i, 1);
				}

			}
		});

		btn_About.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent(start.this, About.class);
				startActivity(i);
			}
		});

	}
}